<?php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        $news = new Reale_Model_News();
        $news = $news->fetch(3);
        $this->view->assign('news',$news);
    }
    

	public function changepasswordAction() {
		$request = $this->getRequest ();
		$oldpassword = $request->getParam ( 'txtoldpass' );
		$newpassword = $request->getParam ( 'txtpasswd' );
		$auth_details = Zend_Auth::getInstance()->getIdentity();
		$auth_id = $auth_details['identity'];
		//print_r($request->getParams());
		if (isset ( $newpassword ) && isset ( $oldpassword )) {
			$where [] = 'user_id="'.$auth_id.'"';
			$where [] = 'sec_passwd ="'. $oldpassword .'"';
			try {
			$n = Zend_Db_Table::getDefaultAdapter ()
			                ->update ( 'auth_user', array ('sec_passwd' => $newpassword ), $where );
			} catch (Exception $e) {
			    $this->_helper->logger($e->getMessage());
			    throw $e;
			}
			if ($n <= 0) {
				$this->view->msg = "Password Not Changed.";
			} else {
			    $this->view->success = 1;
				$this->view->msg = "Password Changed Successfully.";
			}
		}
	
	}

}

